package com.mlink.ai.chat.ui.view

import android.content.Context
import android.util.AttributeSet
import androidx.core.widget.NestedScrollView

class ChatNestedScrollView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0
) : NestedScrollView(context, attrs, defStyleAttr) {
    private var mScrollChanged: OnScrollChanged? = null
    override fun onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int) {
        super.onScrollChanged(l, t, oldl, oldt)
        if (mScrollChanged != null) {
            mScrollChanged!!.onScroll(l, t, oldl, oldt)
        }
    }

    fun setOnScrollChanged(onXiaYiYeScrollChanged: OnScrollChanged?) {
        mScrollChanged = onXiaYiYeScrollChanged
    }

    interface OnScrollChanged {
        /**
         * 滑动的方法
         *
         * @param left    左边
         * @param top     上边
         * @param oldLeft 之前的左边
         * @param oldTop  之前的上边
         */
        fun onScroll(left: Int, top: Int, oldLeft: Int, oldTop: Int)
    }
}